from django.conf import settings
from django.shortcuts import render, redirect

# Create your views here.
from django.urls import reverse
from rest_framework.response import Response
from rest_framework.views import APIView

context = {
    "url": settings.URL
}


# 用户注册
class RegisterView(APIView):

    def post(self,request):
        data = request.POST
        username = data['username']
        password = data['password']
        password2 = data['password2']
        print(f"-用户注册-\n账号：{username}\n密码：{password},\n确认密码：{password2}")

        return render(request,"register.html",context=context)


    def get(self,request):
        return render(request, "register.html", context=context)


# 用户登录
class LoginView(APIView):
    context = {
        "url": settings.URL
    }

    def post(self, request):
        data = request.POST
        username = data['username']
        password = data['password']
        print(f"-用户登录-\n账号：{username}\n密码：{password}")

        return Response(f"-用户登录-\n账号：{username}\n密码：{password}")

    def get(self,request):

        return Response("ok")